Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

Added ability to opt back in#59

Open
Aaron1011 wants to merge 1 commit intodfm:masterfrom
Aaron1011:opt_in
Open

Added ability to opt back in#59
Aaron1011 wants to merge 1 commit intodfm:masterfrom
Aaron1011:opt_in

Conversation

@Aaron1011
Copy link
Copy Markdown
Contributor

No description provided.

@bsdlp
Copy link
Copy Markdown

bsdlp commented Dec 2, 2013

How about explicit opt-in via starring the repo? https://github.com/resume/resume.github.com/blob/master/js/githubresume.js#L112

@Aaron1011
Copy link
Copy Markdown
Contributor Author

@dfm: Does this look good to merge?

@Aaron1011
Copy link
Copy Markdown
Contributor Author

@dfm: Ping

2 similar comments
@Aaron1011
Copy link
Copy Markdown
Contributor Author

@dfm: Ping

@Aaron1011
Copy link
Copy Markdown
Contributor Author

@dfm: Ping

@dandv dandv mentioned this pull request Mar 14, 2014
Copy link
Copy Markdown

@ilystsov ilystsov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've switched to using random.choices which can generate the list of characters in one call rather than iterating with a list comprehension.
I used an f-string to format the auth_url
Instead of just urllib.urlencode, I've used urllib.parse.urlencode. This is the more modern way of importing it, especially if you're using Python 3.
I used a more conventional way to define the dictionary params.

Comment thread osrc/frontend.py
Comment on lines +171 to +182
def opt_in_login(username):
state = "".join([random.choice(string.ascii_uppercase + string.digits)
for x in range(24)])
flask.session["state"] = state
params = dict(
client_id=flask.current_app.config["GITHUB_ID"],
redirect_uri=flask.url_for(".opt_in_callback", username=username,
_external=True),
state=state,
)
return flask.redirect("https://github.com/login/oauth/authorize?{0}"
.format(urllib.urlencode(params)))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def opt_in_login(username):
state = "".join([random.choice(string.ascii_uppercase + string.digits)
for x in range(24)])
flask.session["state"] = state
params = dict(
client_id=flask.current_app.config["GITHUB_ID"],
redirect_uri=flask.url_for(".opt_in_callback", username=username,
_external=True),
state=state,
)
return flask.redirect("https://github.com/login/oauth/authorize?{0}"
.format(urllib.urlencode(params)))
def opt_in_login(username):
state = ''.join(random.choices(string.ascii_uppercase + string.digits, k=24))
flask.session["state"] = state
params = {
'client_id': flask.current_app.config["GITHUB_ID"],
'redirect_uri': flask.url_for('.opt_in_callback', username=username, _external=True),
'state': state,
}
auth_url = f"https://github.com/login/oauth/authorize?{urllib.parse.urlencode(params)}"
return flask.redirect(auth_url)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants